home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
051-075
/
051
/
bison
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-13
|
3KB
|
121 lines
/* Top level entry point of bison,
copyright (C) 1984 Bob Corbett and Richard Stallman
Permission is granted to anyone to make or distribute verbatim copies of this program
provided that the copyright notice and this permission notice are preserved;
and provided that the recipient is not asked to waive or limit his right to
redistribute copies as permitted by this permission notice;
and provided that anyone possessing an executable copy
is granted access to copy the source code, in machine-readable form,
in some reasonable manner.
Permission is granted to distribute derived works or enhanced versions of
this program under the above conditions with the additional condition
that the entire derivative or enhanced work
must be covered by a permission notice identical to this one.
Anything distributed as part of a package containing portions derived
from this program, which cannot in current practice perform its function usefully
in the absense of what was derived directly from this program,
is to be considered as forming, together with the latter,
a single work derived from this program,
which must be entirely covered by a permission notice identical to this one
in order for distribution of the package to be permitted.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
#include <stdio.h>
extern int lineno;
extern int verboseflag;
main(argc, argv)
int argc;
char *argv[];
{
lineno = 0;
getargs(argc, argv);
openfiles();
/* read the input. Copy some parts of it to fguard, faction, ftable and fattrs.
In file reader.
The other parts are recorded in the grammar; see gram.h. */
reader();
/* record other info about the grammar. In files derives and nullable. */
set_derives();
set_nullable();
/* convert to nondeterministic finite state machine. In file LR0.
See state.h for more info. */
generate_states();
/* make it deterministic. In file lalr. */
lalr();
/* Find and record any conflicts: places where one token of lookahead is not
enough to disambiguate the parsing. Resolve conflicts. In file
conflicts. */
initialize_conflicts();
/* print information about results, if requested. In file print. */
if (verboseflag)
verbose();
else
terse();
/* output the tables and the parser to ftable. In file output. */
output();
done(0);
}
/* functions to report errors which prevent a parser from being generated */
fatal(s)
char *s;
{
fprintf(stderr, "\nerror at line %d: %s\n", lineno, s);
done(1);
}
fatals(fmt, s)
char *fmt;
char *s;
{
char buffer[200];
sprintf(buffer, fmt, s);
fatal(buffer);
}
toomany(s)
char *s;
{
char buffer[200];
sprintf(buffer, "limit exceeded, too many %s", s);
fatal(buffer);
}
berror(s)
char *s;
{
fprintf(stderr, "internal error, %s\n", s);
#ifdef unix
abort();
#else
exit(1);
#endif
}